package cn.itcast.n3_Java线程;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.locks.LockSupport;

import static cn.itcast.util.Sleeper.sleep;

/**
 * @program: juc
 * @description:
 * @author: flyduck
 * @create: 2024-08-29 16:39
 **/
@Slf4j(topic = "c.Test22_interrupt方法_park线程打断后再次执行park不起作用_调用静态方法interrupted清空打断标记")
public class Test22_interrupt方法_park线程打断后再次执行park不起作用_调用静态方法interrupted清空打断标记 {

    public static void main(String[] args) {
        test3();
    }

    private static void test3(){
        Thread t1 = new Thread(() -> {
            log.debug("park...");
            LockSupport.park();
            log.debug("unpark...");
            log.debug("打断状态：{}", Thread.interrupted());//打断状态：true

            log.debug("park...");
            LockSupport.park();
            log.debug("unpark...");
        }, "t1");
        t1.start();

        sleep(1);
        t1.interrupt();
    }
}
